<template>
    <div id="tmpl">
        <div id="list">
            <div class="title">
                <h4>{{imginfo.title}}</h4>
                <p>{{imginfo.add_time | datafmt('YYYY-MM-DD HH:mm:ss')}} {{imginfo.click}}次浏览 分类：经济民生</p>
            </div>
            <div class="mui-content">
                <ul class="mui-table-view mui-grid-view mui-grid-9">
                    <li v-for="(item, index) in list" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                        <img class="preview-img"  :src="item.src" height="100" @click="$preview.open(index, list)">
                    </li>

                </ul>
            </div>
            <div id="content">
                <p v-html="imginfo.content"></p>
            </div>

        </div>
        <comment :id='id'></comment>
    </div>
</template>

<script>
import { Toast } from 'mint-ui';
import common from '../../kits/common.js';
import comment from '../subcom/comment.vue';
export default {
    components: {
        comment
    },
    data() {
        return {
            id: 0,
            list: [
                
            ],
            imginfo: []
        }
    },
    created() {
        this.id = this.$route.params.id;
        this.getimginfo();
        this.getimgs();
    },
    methods: {
        getimgs(imgid) {
            var url = common.apidomain + '/api/getthumimages/' +this.id;
            this.$http.get(url).then(function(res) {
                if (res.body.status != 0) {
                    Toast(res.body.message);
                    return;
                }
                res.body.message.forEach(function(element) {
                    var img=document.createElement('img');
                    img.src=element.src;
                    element.w=img.width;
                    element.h=img.height;
                });
                this.list = res.body.message;
            })
        },
        getimginfo() {
            var url = common.apidomain + '/api/getimageInfo/' + this.id;
            this.$http.get(url).then(function(res) {
                if (res.body.status != 0) {
                    Toast(res.body.message);
                    return;
                }
                this.imginfo = res.body.message[0];

            })
        }
    }

}
</script>
<style scoped>
#list .title h4 {
    color: #0094ff;
    font-weight: bolder;
    padding-left: 5px;
    padding-top: 5px;
}

#list .title p {
    color: rgba(0, 0, 0, 0.4);
    padding: 5px 0 10px 5px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
    margin:0px;
}
.mui-content ul{
    padding:5px;
}
.mui-grid-view.mui-grid-9 .mui-table-view-cell{
    margin:16px;
    padding: 0px;
}
.mui-content > .mui-table-view:first-child{
     margin-top:0px; 
}
.mui-content img {
    width: 100px;
    height: 100px;
    float:left;
}

#content p {
    padding: 5px;
    color: rgba(0, 0, 0, 0.6);
    font-size: 14px;
}
</style>


